package com.black.platform.area.web;

import com.black.platform.area.po.Area;
import com.black.platform.area.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author linwenfeng
 */
@RestController
@RequestMapping("/shop/open/api/area")
@Api(tags = "省市区接口")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AreaController {

    private final AreaService areaService;

    /**
     * 分页获取
     */
    @GetMapping("/listByPid")
    @ApiOperation(value = "获取省市区信息", notes = "根据省市区的pid获取地址信息")
    @ApiImplicitParam(name = "pid", value = "省市区的pid(pid为0获取所有省份)", required = true, dataType = "String")
    public ResponseEntity<List<Area>> listByPid(Long pid) {
        return ResponseEntity.ok(areaService.listByPid(pid));
    }
}
